package com.emagic.manage.modules.main.presenter;

import com.emagic.manage.data.entities.response.RoomsResponse;
import com.emagic.manage.modules.main.domain.GetRoomListUseCase;
import com.emagic.manage.mvp.domain.UseCase;
import com.emagic.manage.mvp.presenters.PageLimitPresenter;
import com.xitaiinfo.library.injections.ActivityScope;

import javax.inject.Inject;

/**
 * Created by xiatian on 2017/11/1.
 */
@ActivityScope
public class RoomsListPresenter extends PageLimitPresenter<RoomsResponse> {

    private GetRoomListUseCase useCase;
    private String userid;

    @Inject
    public RoomsListPresenter(GetRoomListUseCase useCase){
        this.useCase = useCase;
    }


    @Override
    public void onResume() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onDestroy() {
        useCase.unSubscribe();
    }

    @Override
    protected UseCase<RoomsResponse> buildPageUseCase(int pageOffset, int pageSize) {
        useCase.setUserid(userid);
        return useCase;
    }

    public void loadFirst(String userid){
        this.userid = userid;
        super.fetchFirst();
    }
}
